<%@ page import="com.fhd.constant.Constants" %>
<%@ page import="com.fhd.pojo.Bill" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 44252
  Date: 2025/4/3
  Time: 21:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商户订单</title>
</head>
<body>
<h2>以下是所有订单：</h2>
<%--回到商户主页--%>
<a href="<%=request.getContextPath()%>/jsp/merchantFrame.jsp">返回</a>
<br>
<%
    String message = (String)request.getSession().getAttribute(Constants.MERCHANT_CANCEL_BILL_MESSAGE);
    if (message != null) {
        // 取消订单返回信息
        out.write("<h4 style=\"color: red\">" + message + "</h4>");
        request.getSession().removeAttribute(Constants.MERCHANT_CANCEL_BILL_MESSAGE);
    }

    String message0 = (String)request.getSession().getAttribute(Constants.MERCHANT_CONFIRM_BILL_MESSAGE);
    if (message0 != null) {
        // 确认订单返回信息
        out.write("<h4 style=\"color: red\">" + message0 + "</h4>");
        request.getSession().removeAttribute(Constants.MERCHANT_CONFIRM_BILL_MESSAGE);
    }

    String message1 = (String)request.getSession().getAttribute(Constants.MERCHANT_BILL_MESSAGE);
    if (message1 != null) {
        // 没有订单记录
        out.write("<h4 style=\"color: red\">" + message1 + "</h4>");
        request.getSession().removeAttribute(Constants.MERCHANT_BILL_MESSAGE);
    } else {
        // 有订单记录，把其全部打出来
        Object object = request.getSession().getAttribute(Constants.MERCHANT_BILL_SESSION);
        if (object != null) {
            ArrayList<Bill> bills = (ArrayList<Bill>) object;
            for (Bill bill : bills) {
                out.print("订单编号："+ bill.getId() + "<br>");
                out.print("客户昵称：" + bill.getClientUserName() + "<br>");
                out.print("房型名：" + bill.getHouseName() + "<br>");
                out.print("订单总金额："+ bill.getMoney() + "<br>");
                out.print("订单数量："+ bill.getNumber() + "<br>");
                out.print("订单时间：" + bill.getStartTime() + "~~~" + bill.getEndTime() + "<br>");
                int situation = bill.getSituation();
                if (situation == 1) {
                    out.write("状态：待使用");

%>
<br><br>
<form action="<%=request.getContextPath()%>/merchant.do" method="post">
    <input type="hidden" name="method" value="merchantCancelBill">
    <input type="hidden" name="billId" value="<%=bill.getId()%>">
    <input type="hidden" name="clientId" value="<%=bill.getClientId()%>">
    <input type="hidden" name="merchantId" value="<%=bill.getMerchantId()%>">
    <input type="hidden" name="houseId" value="<%=bill.getHouseId()%>">
    <input type="hidden" name="money" value="<%=bill.getMoney()%>">
    <input type="hidden" name="number" value="<%=bill.getNumber()%>">
    <input type="submit" name="situation" value="客户已入住">
    <input type="submit" name="situation" value="取消订单">
</form>
<%
                } else if (situation == 2) {
                    out.write("状态：已使用<br>");
                } else if (situation ==3) {
                    out.write("状态：商家已取消<br>");
                } else if (situation == 4) {
                    out.print("状态：客户已取消<br>");
                }
                out.write("=======================");
                out.write("<br>");
            }
        } else {
            out.write("没有充值数据，请充值先噢<br>");
        }
    }
%>
</body>
</html>
